#include "stdafx.h"
#include "CppUnitTest.h"

#include <HSModel/WorldObject.h>
#include <HSModel/Tree.h>
#include <HSModel/World.h>
#include <HSModel/Model3DStorage.h>
#include <HSModel/HeightMap.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace HSModelTests
  {
  TEST_CLASS(TreeTests)
    {
    public:
      TEST_METHOD(ShouldCreateCorrectly)
        {
        World world(HeightMap(1, 1));
        Tree tree = Tree(world, ETreeType::TT_DEFAULT_TREE);

        TVector3 expected_position = TVector3(0.0,0.0,0.0);
        TVector3 actual_position = tree.GetPosition();

        Assert::AreEqual(expected_position.X(), actual_position.X());
        Assert::AreEqual(expected_position.Y(), actual_position.Y());
        Assert::AreEqual(expected_position.Z(), actual_position.Z());
        }

      TEST_METHOD(ShouldPlantCorrectly)
        {
        World world(HeightMap(1, 1));

        Tree tree = Tree(world, ETreeType::TT_DEFAULT_TREE);
        tree.SetPosition(50.0, 25.0, 10.0);

        TVector3 expected_position = TVector3(50.0, 25.0, 10.0);
        TVector3 actual_position = tree.GetPosition();
        
        Assert::AreEqual(expected_position.X(), actual_position.X());
        Assert::AreEqual(expected_position.Y(), actual_position.Y());
        Assert::AreEqual(expected_position.Z(), actual_position.Z());
        }

      TEST_METHOD(ShouldChangeStateOnAnimationProperly)
        {
        World world(HeightMap(1, 1));

        Tree tree = Tree(world, ETreeType::TT_DEFAULT_TREE);

        Assert::AreEqual(std::string("DEFAULT_TREE_0"), tree.GetType());
        
        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_0"), tree.GetType());

        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_1"), tree.GetType());

        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_1"), tree.GetType());

        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_2"), tree.GetType());

        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_2"), tree.GetType());

        tree.NextFrame();
        Assert::AreEqual(std::string("DEFAULT_TREE_1"), tree.GetType());
        }

    };
  }